package mx.com.crowdgine.display.animation.glsl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import mx.com.crowdgine.display.animation.Animation;
import mx.com.crowdgine.display.animation.AnimationFrame;
import mx.com.crowdgine.display.jogl.shader.ShaderObject;

public class GLSLAnimation implements Animation {
	
	private String vertexShader;
	private String fragmentShader;
	
	private Map<String, Object> parameters = new HashMap<String, Object>();
	private Map<String, Integer> parameterSizes = new HashMap<String, Integer>();
	private Map<String, Integer> parameterLengths = new HashMap<String, Integer>();
	private Map<String, Object> dynamicParameters = new HashMap<String, Object>();
	
	private List<AnimationFrame> frames = new ArrayList<AnimationFrame>();
	private int animationIndex;
	
	private ShaderObject shaderObject;
	
	public GLSLAnimation(String fragmentShader) {
		this.fragmentShader = fragmentShader;
	}
	
	public GLSLAnimation(String vertexShader, String fragmentShader) {
		this.fragmentShader = fragmentShader;
		this.vertexShader = vertexShader;
	}

	public String getVertexShader() {
		return vertexShader;
	}

	public void setVertexShader(String vertexShader) {
		this.vertexShader = vertexShader;
	}

	public String getFragmentShader() {
		return fragmentShader;
	}

	public void setFragmentShader(String fragmentShader) {
		this.fragmentShader = fragmentShader;
	}
	
	public void setParameter(String name, Object value) {
		this.parameters.put(name, value);
		
		if(value instanceof float[])
			this.parameterSizes.put(name, ((float[])value).length);
		if(value instanceof int[])
			this.parameterSizes.put(name, ((int[])value).length);
		
	}
	
	public void setParameter(String name, Object value, int size) {
		this.parameters.put(name, value);
		this.parameterSizes.put(name, size);
	}
	
	public void setParameter(String name, Object value, int size, int length) {
		this.parameters.put(name, value);
		this.parameterSizes.put(name, size);
		this.parameterLengths.put(name, length);
	}
	
	public void setDynamicParameter(String name, Object value) {
		this.dynamicParameters.put(name, value);
	}
	
	public Object getDynamicParameter(String name) {
		return this.dynamicParameters.get(name);
	}
	
	public Map<String, Object> getDynamicParameters() {
		return this.dynamicParameters;
	}
	
	public Set<String> getParameterNames() {
		return this.parameters.keySet();
	}
	
	public Object getParameter(String name) {
		return this.parameters.get(name);
	}
	
	public int getParameterSize(String name) {
		return this.parameterSizes.get(name);
	}
	
	public int getParameterLength(String name) {
		return this.parameterLengths.get(name);
	}

	public ShaderObject getShaderObject() {
		return shaderObject;
	}

	public void setShaderObject(ShaderObject shaderObject) {
		this.shaderObject = shaderObject;
	}
	
	public List<AnimationFrame> getFrames() {
		return this.frames;
	}

	public int getAnimationIndex() {
		return animationIndex;
	}

	public void setAnimationIndex(int animationIndex) {
		this.animationIndex = animationIndex;
	}
	
	
	
	
}
